package weak_20241227_29.stream;

import java.util.ArrayList;

/**
 * @author zdl
 * @date 2024/12/27
 */
public class Demo18 {
    public static void main(String[] args) {
        //18. 将一个字符串列表中的每个字符串长度求和
        ArrayList<String> list = new ArrayList<>();
        list.add("asd"); //3
        list.add("qweqw"); //5
        list.add("okklhj"); //6
        list.add("那看来");//3
        Integer reduce = list.stream().map(s -> s.length()).reduce(0, (i1, i2) -> i1 + i2);
        System.out.println(reduce);
    }
}
